﻿:root {
      --bg: #f4f7fb;
      --card: #ffffff;
      --text: #1d2735;
      --muted: #5f6b7a;
      --brand: #0c6b58;
      --brand-2: #0a5849;
      --line: #d8e0ea;
      --head: #e9f4f1;
      --zebra: #fbfdff;
      --danger: #b92c2c;
    }
    * { box-sizing: border-box; }
    body {
      margin: 0;
      min-height: 100vh;
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
      background: linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
      color: var(--text);
      padding-top: 68px;
      overflow: hidden;
    }
    .topbar {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      width: 100%;
      z-index: 1000;
      background: #ffffff;
      border-bottom: 1px solid var(--line);
    }
    .topbar-inner {
      max-width: none;
      margin: 0 auto;
      padding: 12px clamp(12px, 2vw, 28px);
      display: flex;
      gap: 14px;
      align-items: center;
      flex-wrap: wrap;
    }
    .brand {
      font-weight: 700;
      color: var(--brand);
      margin-right: 10px;
    }
    .nav {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
    }
    .nav a {
      text-decoration: none;
      color: var(--text);
      border: 1px solid var(--line);
      padding: 6px 10px;
      border-radius: 8px;
      background: #fff;
      font-size: 14px;
    }
    .nav a:hover { border-color: var(--brand); }
    .nav a[aria-current="page"] {
      background: var(--brand);
      color: #fff;
      border-color: var(--brand);
      pointer-events: none;
      cursor: default;
    }
    main {
      max-width: none;
      margin: 24px auto;
      padding: 20px clamp(12px, 2vw, 28px) 28px;
    }
    .panel {
      background: var(--card);
      border: 1px solid var(--line);
      border-radius: 12px;
      padding: 18px;
    }
    .panel-sticky {
      position: fixed;
      top: 74px;
      left: 0;
      width: 100%;
      z-index: 1100;
      background: var(--card);
      border: 1px solid var(--line);
      border-radius: 12px 12px 0 0;
      padding: 18px;
      margin: 0;
    }
    h1 { margin: 0 0 10px; }
    p { color: var(--muted); margin: 0 0 14px; }
    .toolbar {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      align-items: end;
      margin-bottom: 8px;
    }
    .field-group label {
      display: block;
      font-size: 13px;
      margin-bottom: 4px;
      color: #294455;
      font-weight: 600;
    }
    input[type="month"] {
      border: 1px solid var(--line);
      border-radius: 8px;
      padding: 8px 10px;
      font-size: 14px;
      background: #fff;
      min-width: 160px;
    }
    .btn {
      text-decoration: none;
      background: var(--brand);
      color: #fff;
      border: 0;
      border-radius: 8px;
      padding: 8px 12px;
      font-size: 14px;
      display: inline-block;
      cursor: pointer;
    }
    .btn:hover { background: var(--brand-2); }
    .btn-danger {
      background: var(--danger);
    }
    .btn-danger:hover {
      background: #982424;
    }
    .status {
      margin-top: 8px;
      margin-bottom: 10px;
      font-size: 14px;
      font-weight: 600;
      color: #1f6d3a;
    }
    .status.error { color: var(--danger); }
    .sheet-wrap {
      border: 1px solid var(--line);
      border-radius: 10px;
      overflow: auto;
      background: #fff;
      position: fixed;
      top: 300px;
      left: 0;
      width: 100%;
      bottom: 12px;
    }
    table {
      width: 100%;
      border-collapse: collapse;
      min-width: 0;
      table-layout: fixed;
    }
    th, td {
      border: 1px solid var(--line);
      padding: 0;
      font-size: 13px;
      vertical-align: middle;
    }
    th {
      position: sticky;
      top: 0;
      z-index: 20;
      background: var(--head);
      color: #1f3a33;
      text-align: left;
      font-weight: 700;
      white-space: normal;
      padding: 8px 10px;
    }
    tbody tr:nth-child(even) td {
      background: var(--zebra);
    }
    .col-date, .col-day {
      font-weight: 700;
      text-align: center;
      white-space: nowrap;
      padding: 8px 6px;
    }
    .col-date { width: 124px; }
    .col-day { width: 78px; }
    .col-period {
      font-weight: 700;
      text-align: left;
      white-space: nowrap;
      width: 126px;
      padding: 8px 6px;
    }
    .cell-input {
      width: 100%;
      border: 0;
      border-bottom: 1px solid #d7e2ef;
      border-radius: 0;
      padding: 6px 6px 5px;
      background: transparent;
      font-size: 12px;
      font-family: "Times New Roman", Times, serif;
      min-height: 30px;
    }
    .cell-textarea {
      width: 100%;
      border: 0;
      border-bottom: 1px solid #d7e2ef;
      border-radius: 0;
      padding: 6px 6px 5px;
      background: transparent;
      font-size: 12px;
      font-family: "Times New Roman", Times, serif;
      line-height: 1.3;
      resize: none;
      min-height: 48px;
      white-space: pre-wrap;
      overflow-wrap: anywhere;
      overflow: hidden;
    }
    .cell-input:focus {
      outline: 0;
      border-bottom-color: #3b7cc5;
      background: #f3f8ff;
      box-shadow: none !important;
    }
    .cell-textarea:focus {
      outline: 0;
      border-bottom-color: #3b7cc5;
      background: #f3f8ff;
      box-shadow: none !important;
    }
    .row-actions {
      display: flex;
      gap: 6px;
      justify-content: center;
      padding: 6px;
    }
    .btn-mini {
      border: 0;
      border-radius: 6px;
      padding: 4px 7px;
      font-size: 12px;
      color: #fff;
      cursor: pointer;
      background: var(--brand);
    }
    .btn-mini:hover { background: var(--brand-2); }
    .btn-mini.danger { background: var(--danger); }
    .btn-mini.danger:hover { background: #982424; }
    .date-cell-wrap {
      display: grid;
      gap: 6px;
      justify-items: center;
      padding: 8px 6px;
    }
    .date-tools {
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
      justify-content: center;
    }
    .period-cell-wrap {
      display: grid;
      gap: 6px;
      justify-items: start;
      padding: 8px 6px;
      text-align: left;
    }
    .period-title {
      width: 100%;
      text-align: left;
    }
    .period-rep {
      width: 120px;
      border: 0;
      border-bottom: 1px solid #d7e2ef;
      border-radius: 0;
      padding: 4px 2px;
      font-size: 12px;
      font-family: "Times New Roman", Times, serif;
      background: transparent;
      display: block;
      margin: 0 auto;
      text-align: center;
      font-weight: 700;
    }
    .cell-input[list] {
      appearance: none;
      -webkit-appearance: none;
      -moz-appearance: textfield;
      background-image: none !important;
      padding-right: 8px;
    }
    .cell-input[list]::-webkit-calendar-picker-indicator {
      display: none !important;
      opacity: 0 !important;
    }
    .period-tools {
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
      justify-content: center;
    }
    .entry-cell {
      vertical-align: top !important;
      padding-top: 4px !important;
      padding-right: 6px !important;
    }
    .entry-cell .cell-input,
    .entry-cell .cell-textarea,
    .entry-cell .period-rep {
      text-align: right;
      margin-left: auto;
      margin-right: 0;
      width: 100%;
    }
    .entry-cell .cell-input:not(.period-rep),
    .entry-cell .cell-textarea:not(.period-rep) {
      text-align: left;
      margin-left: 0;
      margin-right: auto;
    }
    .entry-cell .period-title {
      text-align: right;
      width: 100%;
    }
    .entry-cell .period-tools {
      justify-content: flex-end;
    }
    .sheet-editor-selected {
      outline: 0 !important;
      box-shadow: none !important;
      background: inherit !important;
    }
    .help {
      margin-top: 16px;
      padding: 14px;
      background: #eef6f4;
      border: 1px solid #cfe4de;
      border-radius: 10px;
      color: #25443c;
    }
    .saved-box {
      margin-top: 14px;
      padding: 12px;
      border: 1px solid var(--line);
      border-radius: 10px;
      background: #fafdff;
    }
    .saved-actions {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
      align-items: end;
    }
    .style-box {
      margin: 10px 0 12px;
      padding: 10px 12px;
      border: 1px solid var(--line);
      border-radius: 10px;
      background: #f7fbff;
    }
    .style-tools {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      align-items: end;
    }
    .style-tools .field-group {
      min-width: 120px;
    }
    .style-tools input[type="number"],
    .style-tools input[type="color"],
    .style-tools select {
      width: 100%;
    }
    .style-check {
      display: flex;
      gap: 6px;
      align-items: center;
      padding: 4px 0;
      font-size: 14px;
      color: #294455;
      font-weight: 600;
    }
    .style-target {
      margin-top: 6px;
      font-size: 12px;
      color: #49617c;
    }
    select {
      border: 1px solid var(--line);
      border-radius: 8px;
      padding: 8px 10px;
      font-size: 14px;
      background: #fff;
      min-width: 190px;
    }
    .print-head {
      display: none;
    }
    .print-head h2 {
      margin: 0 0 6px;
      font-size: 16px;
      text-align: center;
      color: #1f3a33;
    }
    .print-meta {
      display: flex;
      justify-content: center;
      gap: 20px;
      font-size: 12px;
      color: #2f435f;
      margin-bottom: 8px;
    }
    @page {
      size: A4 landscape;
      margin: 8mm;
    }
    @media print {
      .topbar,
      .toolbar,
      .saved-box,
      .style-box,
      .help,
      .status,
      h1,
      p {
        display: none !important;
      }
      .print-head {
        display: block !important;
      }
      body {
        padding-top: 0;
        overflow: visible;
      }
      .panel-sticky {
        position: static !important;
        width: auto !important;
        top: auto !important;
        left: auto !important;
        border: 0 !important;
        border-radius: 0 !important;
        padding: 0 !important;
      }
      .panel {
        border: 0;
        padding: 0;
      }
      .print-head {
        margin: 0 0 8px;
        padding: 6px 8px 8px;
        border: 1px solid #bcd4ee;
        border-radius: 8px;
        background: #eef6ff;
      }
      .print-head h2 {
        margin: 0 0 4px;
        font-size: 16px;
        color: #17385a;
        text-align: center;
      }
      .print-meta {
        margin: 0;
        font-size: 11px;
        color: #1b4268;
      }
      .sheet-wrap {
        border: 0;
        overflow: visible;
        position: static !important;
        top: auto !important;
        left: auto !important;
        width: auto !important;
        bottom: auto !important;
      }
      .sheet-wrap table {
        width: 100%;
        table-layout: fixed;
        border-collapse: collapse;
      }
      th {
        position: static;
        font-size: 9px;
        line-height: 1.2;
        padding: 3px 4px;
        white-space: normal;
        word-break: break-word;
        background: #dfefff;
        color: #17385a;
        border-color: #bcd4ee;
      }
      td {
        font-size: 8.5px;
        line-height: 1.2;
        padding: 2px 3px;
        white-space: normal;
        word-break: break-word;
        background: #f6fbff;
        border-color: #c9dcf1;
        color: #17324c;
      }
      .cell-input {
        border: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        font-size: 8.5px;
        min-height: 0;
        padding: 1px 2px;
      }
      .cell-textarea {
        border: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        font-size: 8.5px;
        line-height: 1.2;
        min-height: 0;
        padding: 1px 2px;
        resize: none;
      }
      .period-rep {
        border: 0 !important;
        background: transparent !important;
        padding: 0 !important;
        font-size: 8.5px !important;
        font-weight: 700;
        width: 100% !important;
        text-align: center !important;
        margin: 0 !important;
        display: block;
      }
      .sheet-wrap th:last-child,
      .sheet-wrap td:last-child {
        display: none;
      }
      .sheet-wrap tbody tr {
        display: table-row !important;
      }
      .row-actions,
      .period-tools {
        display: none !important;
      }
      .sheet-wrap th:nth-child(1), .sheet-wrap td:nth-child(1) { width: 7%; }
      .sheet-wrap th:nth-child(2), .sheet-wrap td:nth-child(2) { width: 10%; }
      .sheet-wrap th:nth-child(3), .sheet-wrap td:nth-child(3) { width: 5%; }
      .sheet-wrap th:nth-child(4), .sheet-wrap td:nth-child(4) { width: 8%; }
      .sheet-wrap th:nth-child(5), .sheet-wrap td:nth-child(5) { width: 11%; }
      .sheet-wrap th:nth-child(6), .sheet-wrap td:nth-child(6) { width: 9%; }
      .sheet-wrap th:nth-child(7), .sheet-wrap td:nth-child(7) { width: 8%; }
      .sheet-wrap th:nth-child(8), .sheet-wrap td:nth-child(8) { width: 8%; }
      .sheet-wrap th:nth-child(9), .sheet-wrap td:nth-child(9) { width: 10%; }
      .sheet-wrap th:nth-child(10), .sheet-wrap td:nth-child(10) { width: 10%; }
      .sheet-wrap th:nth-child(11), .sheet-wrap td:nth-child(11) { width: 7%; }
      .sheet-wrap th:nth-child(12), .sheet-wrap td:nth-child(12) { width: 7%; }
      tbody tr:nth-child(even) td {
        background: #edf6ff;
      }
    }


/* Stable fixed navigation across pages */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 1000;
}
.topbar-inner {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.brand {
  flex-shrink: 0;
}
.nav {
  flex-wrap: nowrap;
  white-space: nowrap;
}
.nav a {
  flex-shrink: 0;
}

/* Navigation hard lock (prevent any bleed behind nav) */
.topbar {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  z-index: 2147483000 !important;
  background: #ffffff !important;
  border-bottom: 1px solid var(--line) !important;
  isolation: isolate;
}
.topbar-inner {
  position: relative;
  z-index: 1;
  flex-wrap: nowrap !important;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.brand { flex-shrink: 0; }
.nav { flex-wrap: nowrap !important; white-space: nowrap; }
.nav a { flex-shrink: 0; }
body { padding-top: 74px !important; }
