:root {
  --navy: #102a43;
  --navy-2: #163a5f;
  --blue: #147d96;
  --teal: #139a8f;
  --sky: #e8f4f7;
  --ink: #183247;
  --muted: #62788a;
  --line: #dce6ec;
  --paper: #fff;
  --canvas: #f4f7f9;
  --danger: #ba3b46;
  --warning: #bd7924;
  --success: #1b816f;
  --shadow: 0 16px 40px rgba(24, 50, 71, .1);
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
[hidden] { display: none !important; }

.auth-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 10%, rgba(19, 154, 143, .15), transparent 26rem),
    linear-gradient(135deg, #edf5f7 0%, #f8fafb 52%, #eef3f6 100%);
}
.auth-brand { display: inline-flex; gap: 14px; align-items: center; color: var(--navy); text-decoration: none; }
.auth-brand > span, .sidebar-brand > span {
  display: grid; place-items: center; width: 45px; height: 45px; border-radius: 13px;
  overflow: hidden; background: #fff; box-shadow: 0 4px 14px rgba(7, 32, 51, .16);
}
.auth-brand > span img, .sidebar-brand > span img, .setup-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }
.auth-brand strong, .sidebar-brand strong { display: flex; flex-direction: column; line-height: 1.25; }
.auth-brand small, .sidebar-brand small { margin-top: 4px; font-size: 10px; font-weight: 600; letter-spacing: .09em; opacity: .65; }
.auth-brand.inverse { color: #fff; }

.role-select-page { width: min(1160px, calc(100% - 40px)); margin: 0 auto; padding: 34px 0 60px; }
.role-select-content { margin-top: 75px; text-align: center; }
.eyebrow { margin: 0 0 10px; color: var(--teal); font-size: 12px; font-weight: 800; letter-spacing: .16em; }
.role-select-content h1 { margin: 0; color: var(--navy); font-size: clamp(30px, 4vw, 48px); letter-spacing: -.03em; }
.role-select-content > p:not(.eyebrow) { color: var(--muted); }
.role-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; margin: 42px 0 26px; text-align: left; }
.role-grid > a { display: flex; flex-direction: column; min-height: 270px; padding: 30px; border: 1px solid var(--line); border-radius: 22px; background: rgba(255,255,255,.93); box-shadow: var(--shadow); text-decoration: none; transition: transform .2s, box-shadow .2s; }
.role-grid > a:hover { transform: translateY(-4px); box-shadow: 0 22px 50px rgba(24,50,71,.16); }
.role-icon { display: grid; place-items: center; width: 55px; height: 55px; margin-bottom: 25px; border-radius: 16px; color: #fff; font-size: 22px; font-style: normal; font-weight: 800; }
.role-icon.admin { background: #32557a; }.role-icon.teacher { background: var(--teal); }.role-icon.student { background: #d5892f; }
.role-grid strong { color: var(--navy); font-size: 24px; }
.role-grid span { margin-top: 9px; color: var(--muted); line-height: 1.7; }
.role-grid b { margin-top: auto; color: var(--blue); font-size: 14px; }
.security-note { display: inline-flex; gap: 13px; align-items: center; padding: 14px 20px; border-radius: 14px; background: #e3f3ef; color: #25645c; font-size: 13px; }
.security-note span { color: #4a706c; }

.login-layout { display: grid; grid-template-columns: minmax(330px, 43%) 1fr; min-height: 100vh; }
.login-side { display: flex; flex-direction: column; padding: clamp(30px, 5vw, 70px); color: #fff; background: linear-gradient(145deg, rgba(16,42,67,.96), rgba(20,125,150,.94)); }
.role-teacher .login-side { background: linear-gradient(145deg, #0e625e, #178f89); }
.role-student .login-side { background: linear-gradient(145deg, #8b531d, #d28a36); }
.login-side-copy { margin: auto 0; max-width: 520px; }
.login-side-copy p { font-size: 13px; font-weight: 800; letter-spacing: .12em; opacity: .78; }
.login-side-copy h1 { margin: 10px 0 18px; font-size: clamp(35px, 5vw, 62px); line-height: 1.18; letter-spacing: -.04em; }
.login-side-copy > span { line-height: 1.9; opacity: .82; }
.login-side aside { display: flex; flex-direction: column; gap: 5px; padding: 18px; border: 1px solid rgba(255,255,255,.2); border-radius: 15px; background: rgba(255,255,255,.08); font-size: 13px; }
.login-side aside span { opacity: .75; }
.login-form-side { display: grid; place-items: center; padding: 36px; }
.login-card { width: min(100%, 480px); padding: 42px; border: 1px solid var(--line); border-radius: 24px; background: #fff; box-shadow: var(--shadow); }
.back-link { color: var(--muted); font-size: 13px; text-decoration: none; }
.login-card header { margin: 34px 0 30px; }
.login-card header > span { color: var(--teal); font-size: 13px; font-weight: 800; }
.login-card h2 { margin: 8px 0; color: var(--navy); font-size: 32px; }
.login-card header p, .login-help { color: var(--muted); font-size: 14px; }
.login-card form, .setup-form, .form-stack { display: grid; gap: 18px; }
.login-card label, .setup-form label, .field { display: grid; gap: 7px; color: var(--ink); font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 46px; padding: 10px 13px; border: 1px solid #cbd8e0; border-radius: 10px; background: #fff; color: var(--ink); outline: none; transition: border-color .2s, box-shadow .2s; }
textarea { min-height: 105px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(20,125,150,.13); }
.login-card button, .setup-form button, .primary-button { min-height: 48px; border: 0; border-radius: 11px; background: var(--navy); color: #fff; font-weight: 800; cursor: pointer; }
.login-card button:hover, .primary-button:hover { background: var(--navy-2); }
.login-help { text-align: center; }
.form-error { margin-bottom: 18px; padding: 13px 15px; border: 1px solid #f0c8cb; border-radius: 10px; background: #fff0f1; color: #94313a; font-size: 14px; }

.setup-body { display: grid; place-items: center; min-height: 100vh; padding: 30px; background: #eef4f6; }
.setup-card { width: min(100%, 620px); padding: 45px; border-radius: 24px; background: #fff; box-shadow: var(--shadow); }
.setup-mark { display: grid; place-items: center; width: 54px; height: 54px; margin-bottom: 25px; overflow: hidden; border-radius: 16px; background: #fff; box-shadow: 0 5px 16px rgba(24,50,71,.14); }
.setup-card h1 { margin-top: 7px; color: var(--navy); }.setup-card > p { color: var(--muted); }
.setup-form { margin-top: 28px; }.setup-form small { color: var(--muted); font-weight: 400; }
.setup-success { padding: 18px; border-radius: 12px; background: #e8f6f2; color: #176e61; }
.setup-link { display: inline-block; margin-top: 18px; color: var(--blue); font-weight: 800; }

.app-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh; padding: 24px 18px; overflow-y: auto; background: var(--navy); color: #d8e5ee; }
.sidebar-brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 25px; color: #fff; text-decoration: none; }
.sidebar-brand > span { width: 40px; height: 40px; flex: 0 0 auto; }
#role-nav { display: grid; gap: 5px; margin-top: 15px; }
#role-nav a { display: flex; gap: 12px; align-items: center; padding: 12px 13px; border-radius: 10px; color: #bdd0dd; font-size: 14px; font-weight: 700; text-decoration: none; }
#role-nav a:hover, #role-nav a.active { background: rgba(255,255,255,.11); color: #fff; }
.nav-icon { width: 22px; text-align: center; font-size: 16px; }
.logout-button { margin-top: auto; padding: 12px 14px; border: 1px solid rgba(255,255,255,.16); border-radius: 10px; background: transparent; color: #d5e2eb; font-weight: 700; cursor: pointer; }
.app-main { min-width: 0; }
.app-topbar { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; min-height: 74px; padding: 10px 28px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(14px); }
.menu-button { display: none; margin-right: 12px; border: 0; background: transparent; color: var(--navy); font-size: 25px; cursor: pointer; }
.topbar-title { display: flex; flex-direction: column; }.topbar-title strong { color: var(--navy); font-size: 17px; }.topbar-title span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.signed-user { display: flex; gap: 10px; align-items: center; margin-left: auto; border: 0; background: transparent; text-align: left; }
.signed-user > span { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: #dceef1; color: var(--blue); font-weight: 800; }
.signed-user strong { display: flex; flex-direction: column; font-size: 13px; }.signed-user small { color: var(--muted); font-weight: 500; }
.app-content { width: min(1400px, 100%); margin: 0 auto; padding: 30px; }
.loading, .empty-state { padding: 55px 25px; border: 1px dashed #c6d5de; border-radius: 16px; background: rgba(255,255,255,.65); color: var(--muted); text-align: center; }
.page-head { display: flex; gap: 20px; align-items: flex-end; justify-content: space-between; margin-bottom: 25px; }
.page-head h1 { margin: 0; color: var(--navy); font-size: clamp(27px, 3vw, 38px); letter-spacing: -.03em; }
.page-head p { margin: 8px 0 0; color: var(--muted); line-height: 1.6; }
.greeting { margin-bottom: 25px; padding: 27px 30px; border-radius: 20px; color: #fff; background: linear-gradient(130deg, var(--navy), #1a7084); box-shadow: var(--shadow); }
.greeting small { opacity: .7; font-weight: 700; letter-spacing: .1em; }.greeting h1 { margin: 7px 0 5px; font-size: clamp(26px, 4vw, 40px); }.greeting p { margin: 0; opacity: .78; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
.metric { padding: 21px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 8px 26px rgba(24,50,71,.055); }
.metric span { color: var(--muted); font-size: 12px; font-weight: 700; }.metric strong { display: block; margin-top: 10px; color: var(--navy); font-size: 28px; }.metric small { color: var(--teal); }
.panel { margin-bottom: 20px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: 0 8px 28px rgba(24,50,71,.055); overflow: hidden; }
.panel-head { display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 19px 22px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; color: var(--navy); font-size: 18px; }.panel-head p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.panel-body { padding: 22px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field.full, .form-actions.full { grid-column: 1 / -1; }
.field > span { font-size: 12px; font-weight: 800; }.field small { color: var(--muted); font-weight: 400; }
.form-actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 6px; }
.primary-button, .secondary-button, .ghost-button, .danger-button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 9px 16px; border-radius: 9px; font-size: 13px; font-weight: 800; text-decoration: none; cursor: pointer; }
.secondary-button { border: 0; background: var(--teal); color: #fff; }.ghost-button { border: 1px solid #c9d7df; background: #fff; color: var(--ink); }.danger-button { border: 0; background: var(--danger); color: #fff; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }.toolbar input, .toolbar select { width: auto; min-width: 170px; }
.data-table-wrap { width: 100%; overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { padding: 12px 13px; border-bottom: 1px solid var(--line); background: #f7fafb; color: var(--muted); text-align: left; white-space: nowrap; }
.data-table td { padding: 13px; border-bottom: 1px solid #e8eef1; vertical-align: middle; }.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #f9fbfc; }
.badge { display: inline-flex; align-items: center; padding: 4px 9px; border-radius: 99px; background: #e8eff3; color: #3f5d70; font-size: 11px; font-weight: 800; white-space: nowrap; }
.badge.success, .badge.present, .badge.ready, .badge.issued { background: #dff3ed; color: #1b7567; }
.badge.warning, .badge.late, .badge.early, .badge.processing { background: #fff0d8; color: #9a621b; }
.badge.danger, .badge.absent, .badge.rejected { background: #fde4e6; color: #a0343d; }
.badge.excused, .badge.requested { background: #e5ecf8; color: #3b5d8e; }
.lesson-list { display: grid; gap: 14px; }
.lesson-card { display: grid; grid-template-columns: 95px minmax(0, 1fr) auto; gap: 20px; align-items: start; padding: 21px; border: 1px solid var(--line); border-left: 4px solid var(--teal); border-radius: 14px; background: #fff; }
.lesson-time strong { display: block; color: var(--navy); font-size: 18px; }.lesson-time span { color: var(--muted); font-size: 12px; }
.lesson-copy h3 { margin: 0 0 5px; color: var(--navy); }.lesson-copy p { margin: 4px 0; color: var(--muted); line-height: 1.6; }.lesson-copy dl { display: grid; grid-template-columns: 70px 1fr; gap: 4px 10px; margin: 14px 0 0; font-size: 13px; }.lesson-copy dt { color: var(--muted); }.lesson-copy dd { margin: 0; }
.lesson-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.attendance-row select { min-width: 105px; }.attendance-row input[type="number"] { width: 85px; }.attendance-row input[type="text"] { min-width: 180px; }
.status-tabs { display: flex; gap: 5px; flex-wrap: wrap; }.status-tabs button { padding: 7px 10px; border: 1px solid #d2dee5; border-radius: 8px; background: #fff; font-size: 12px; cursor: pointer; }.status-tabs button.active { border-color: var(--teal); background: #e7f5f2; color: #137265; font-weight: 800; }
.quick-links { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; }
.quick-links a { padding: 18px; border: 1px solid var(--line); border-radius: 13px; background: #fff; color: var(--navy); font-weight: 800; text-decoration: none; }.quick-links a span { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; font-weight: 400; }
.profile-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; }.profile-grid div { padding: 15px; border-bottom: 1px solid var(--line); }.profile-grid dt { color: var(--muted); font-size: 11px; }.profile-grid dd { margin: 5px 0 0; font-weight: 700; }
.file-name { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast { position: fixed; z-index: 100; right: 24px; bottom: 24px; max-width: min(420px, calc(100% - 48px)); padding: 14px 18px; border-radius: 11px; background: var(--navy); color: #fff; box-shadow: var(--shadow); font-size: 13px; }.toast.error { background: var(--danger); }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .role-grid { grid-template-columns: 1fr; max-width: 620px; margin-left: auto; margin-right: auto; }
  .role-grid > a { min-height: 220px; }
}
@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; left: -280px; width: 260px; transition: left .22s; box-shadow: 15px 0 40px rgba(5,23,37,.25); }.sidebar.open { left: 0; }
  .menu-button { display: block; }.app-topbar { padding: 9px 16px; }.app-content { padding: 20px 15px; }
  .login-layout { grid-template-columns: 1fr; }.login-side { min-height: 340px; }.login-side aside { display: none; }.login-form-side { padding: 26px 18px; }
  .two-col, .three-col, .quick-links { grid-template-columns: 1fr; }
  .lesson-card { grid-template-columns: 80px 1fr; }.lesson-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 560px) {
  .role-select-page { width: min(100% - 24px, 1160px); }.role-select-content { margin-top: 45px; }
  .role-grid > a { padding: 23px; }.security-note { align-items: flex-start; flex-direction: column; }
  .login-card, .setup-card { padding: 27px 22px; }.login-form-side { padding: 20px 12px; }
  .signed-user strong { display: none; }.topbar-title span { display: none; }
  .metric-grid, .form-grid, .profile-grid { grid-template-columns: 1fr; }
  .page-head { align-items: stretch; flex-direction: column; }.page-head .toolbar { width: 100%; }.toolbar input, .toolbar select { width: 100%; }
  .greeting { padding: 23px 20px; }.panel-body { padding: 16px; }.panel-head { align-items: flex-start; flex-direction: column; }
  .lesson-card { grid-template-columns: 1fr; }.lesson-actions { grid-column: auto; }
}
