  :root {
    --accent: #0f766e;
    --accent-strong: #115e59;
    --accent-soft: #d9f3ee;
    --ink: #162127;
    --ink-soft: #56626a;
    --surface: rgba(255, 255, 255, 0.92);
    --line: rgba(22, 33, 39, 0.09);
    --shadow: 0 16px 32px rgba(16, 24, 40, 0.08);
    --warning-bg: #fff2cc;
    --warning-border: #f4c95d;
    --warning-text: #7c4a03;
    --danger-bg: #fee2e2;
    --danger-border: #fda4af;
    --danger-text: #9f1239;
    --auto-renew-bg: #dbeafe;
    --auto-renew-text: #1d4ed8;
    --success-bg: #dcfce7;
    --success-text: #166534;
    --spot-bg: #eceff3;
    --spot-text: #39424e;
    --annual-bg: #d8f1ef;
    --annual-text: #0f5d58;
    --radius-sm: 12px;
  }

  * {
    box-sizing: border-box;
  }

  body {
    font-family: "Avenir Next", "Hiragino Sans", "Yu Gothic", sans-serif;
    background:
      radial-gradient(circle at top left, rgba(15, 118, 110, 0.18), transparent 28%),
      linear-gradient(180deg, #f3fbf9 0%, #eef4f8 46%, #f8fafc 100%);
    color: var(--ink);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-size: 17px;
    line-height: 1.42;
  }

  #login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1.25rem;
  }

  .login-card {
    width: 100%;
    max-width: 430px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 252, 251, 0.96));
    padding: 1.85rem 1.35rem 1.35rem;
    border-radius: 28px;
    box-shadow: 0 30px 60px rgba(15, 23, 42, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.7);
  }

  .login-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
  }

  .login-card h2 {
    margin: 0.9rem 0 0.5rem;
    font-size: 1.75rem;
    line-height: 1.18;
    color: var(--ink);
  }

  .login-card p {
    color: var(--ink-soft);
    margin: 0 0 1.2rem;
    line-height: 1.45;
    font-size: 0.98rem;
  }

  .app-shell {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 0.85rem 1rem 2.3rem;
  }

  .header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding-top: env(safe-area-inset-top, 0);
  }

  .header-panel {
    background: linear-gradient(145deg, rgba(11, 88, 91, 0.94), rgba(15, 118, 110, 0.92) 58%, rgba(41, 157, 141, 0.85));
    color: #f3fffd;
    border-radius: 0 0 26px 26px;
    box-shadow: 0 18px 36px rgba(15, 118, 110, 0.2);
    overflow: hidden;
  }

  .header-tools {
    padding: 0.9rem 1rem 1rem;
    display: grid;
    gap: 0.72rem;
  }

  .tabs {
    display: flex;
    gap: 0.5rem;
  }

  .tab {
    flex: 1;
    text-align: center;
    padding: 0.85rem 0.7rem;
    font-size: 1rem;
    line-height: 1.15;
    color: rgba(243, 255, 253, 0.74);
    font-weight: 800;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    transition: all 0.2s ease;
  }

  .tab.active {
    color: var(--accent-strong);
    background: rgba(255, 255, 255, 0.94);
    border-color: rgba(255, 255, 255, 0.45);
    box-shadow: 0 10px 22px rgba(11, 88, 91, 0.18);
  }

  .search-box-container {
    position: relative;
  }

  .search-box {
    width: 100%;
    padding: 0.95rem 1rem 0.95rem 2.9rem;
    font-size: 1rem;
    line-height: 1.2;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 17px;
    background: rgba(247, 252, 251, 0.95);
    color: var(--ink);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
  }

  .search-box::placeholder {
    color: #6a7b83;
  }

  .search-box-container::before {
    content: "⌕";
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #5a6a71;
    font-size: 0.98rem;
  }

  .container {
    padding-top: 0.9rem;
  }

  .loading {
    text-align: center;
    padding: 1.7rem;
    color: var(--ink-soft);
    font-size: 0.96rem;
  }

  .error-container,
  .success-container {
    padding: 0.95rem 1rem;
    margin-bottom: 0.95rem;
    border-radius: var(--radius-sm);
    text-align: left;
    line-height: 1.4;
    font-size: 0.95rem;
  }

  .error-container {
    background-color: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid var(--danger-border);
  }

  .success-container {
    background-color: var(--success-bg);
    color: var(--success-text);
    border: 1px solid #86efac;
  }

  .status-overview {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
    margin-bottom: 0.9rem;
  }

  .metric-card {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.78);
    border-radius: 16px;
    padding: 0.8rem 0.85rem 0.78rem;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
  }

  .metric-label {
    font-size: 0.78rem;
    color: var(--ink-soft);
    margin-bottom: 0.18rem;
    line-height: 1.2;
  }

  .metric-value {
    font-size: 1.45rem;
    font-weight: 800;
    line-height: 1.02;
    color: var(--ink);
  }

  .metric-card.is-danger .metric-value {
    color: var(--danger-text);
  }

  .metric-card.is-warning .metric-value {
    color: var(--warning-text);
  }

  .results-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0.1rem 0 0.75rem;
    padding: 0 0.12rem;
  }

  .results-copy {
    font-size: 0.88rem;
    color: var(--ink-soft);
    line-height: 1.32;
  }

  .summary-subcopy {
    margin-top: 0.2rem;
    font-size: 0.8rem;
    color: var(--ink-soft);
  }

  .results-actions {
    display: flex;
    align-items: center;
    gap: 0.55rem;
  }

  .toolbar-btn {
    white-space: nowrap;
  }

  .results-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.95rem;
    height: 1.95rem;
    padding: 0 0.6rem;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.12);
    color: var(--accent-strong);
    font-weight: 800;
    font-size: 0.88rem;
    line-height: 1;
    flex-shrink: 0;
  }

  .card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(251, 253, 253, 0.94));
    border-radius: 20px;
    padding: 1rem 1rem 0.95rem;
    margin-bottom: 0.82rem;
    box-shadow: var(--shadow);
    border: 1px solid rgba(255, 255, 255, 0.82);
    overflow: hidden;
    position: relative;
  }

  .card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    background: var(--accent);
  }

  .card.status-warning {
    background-color: var(--warning-bg);
    border-color: rgba(244, 201, 93, 0.7);
  }

  .card.status-danger {
    background-color: var(--danger-bg);
    border-color: rgba(253, 164, 175, 0.75);
  }

  .card.status-expired-muted {
    background: linear-gradient(180deg, rgba(226, 232, 240, 0.98), rgba(241, 245, 249, 0.95));
    border-color: rgba(148, 163, 184, 0.7);
  }

  .card.status-pending {
    background: linear-gradient(180deg, rgba(255, 251, 235, 0.98), rgba(255, 247, 237, 0.95));
    border-color: rgba(245, 158, 11, 0.28);
  }

  .card.status-warning::before {
    background: #e8a317;
  }

  .card.status-danger::before {
    background: #e11d48;
  }

  .card.status-expired-muted::before {
    background: #64748b;
  }

  .card.status-pending::before {
    background: #d97706;
  }

  .card-subtitle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.7rem;
    margin-bottom: 0.72rem;
  }

  .card-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .card-inline-btn {
    min-width: 5.6rem;
  }

  .card-badges {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
    min-width: 0;
  }

  .badge {
    display: inline-block;
    padding: 0.32rem 0.62rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    line-height: 1.1;
  }

  .badge-spot {
    background: var(--spot-bg);
    color: var(--spot-text);
  }

  .badge-annual {
    background: var(--annual-bg);
    color: var(--annual-text);
  }

  .badge-warning {
    background: #facc15;
    color: #4a3200;
  }

  .badge-danger {
    background: #e11d48;
    color: white;
  }

  .badge-auto {
    background: var(--auto-renew-bg);
    color: var(--auto-renew-text);
  }

  .badge-pending {
    background: #fff2cc;
    color: #7c4a03;
  }

  .badge-complete {
    background: #dcfce7;
    color: #166534;
  }

  .badge-file {
    background: #dbeafe;
    color: #1d4ed8;
  }

  .badge-file-muted {
    background: #e5e7eb;
    color: #4b5563;
  }

  .contract-meta {
    display: grid;
    gap: 0.58rem;
  }

  .info-row {
    display: grid;
    grid-template-columns: 4.7rem minmax(0, 1fr);
    gap: 0.72rem;
    align-items: start;
  }

  .info-label {
    font-size: 0.76rem;
    line-height: 1.2;
    font-weight: 800;
    color: var(--ink-soft);
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding-top: 0.14rem;
  }

  .info-value {
    min-width: 0;
    word-break: break-word;
    font-size: 1.02rem;
    line-height: 1.32;
    color: var(--ink);
  }

  .company-name {
    font-size: 1.12rem;
    font-weight: 800;
    color: var(--ink);
  }

  .date-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
    margin-top: 0.15rem;
  }

  .single-row {
    margin-top: 0;
  }

  .date-card {
    padding: 0.78rem 0.82rem 0.74rem;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(15, 118, 110, 0.08), rgba(15, 118, 110, 0.03));
    border: 1px solid rgba(15, 118, 110, 0.14);
  }

  .date-card-end {
    background: linear-gradient(180deg, rgba(29, 78, 216, 0.08), rgba(29, 78, 216, 0.03));
    border-color: rgba(29, 78, 216, 0.14);
  }

  .date-label {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: var(--ink-soft);
    margin-bottom: 0.28rem;
  }

  .date-value {
    font-size: 1.06rem;
    font-weight: 800;
    line-height: 1.15;
    color: var(--ink);
  }

  .footer-info {
    text-align: center;
    font-size: 0.78rem;
    color: var(--ink-soft);
    margin-top: 1.6rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  }

  .highlight {
    background-color: #fde68a;
    color: #3b2f05;
    border-radius: 0.28rem;
    padding: 0 0.12rem;
  }

  .empty-state {
    background: var(--surface);
    border-radius: 20px;
    padding: 1.35rem 1rem;
    text-align: center;
    color: var(--ink-soft);
    box-shadow: var(--shadow);
    border: 1px solid rgba(255, 255, 255, 0.78);
    line-height: 1.38;
    font-size: 0.96rem;
  }

  .pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.4rem;
    padding: 0.2rem 0.1rem 0;
  }

  .pagination .btn-secondary {
    min-width: 6.2rem;
  }

  .pagination-status {
    flex: 1;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--ink-soft);
  }

  .form-group {
    margin-bottom: 1rem;
  }

  .form-label {
    display: block;
    font-weight: 800;
    margin-bottom: 0.42rem;
    color: var(--ink);
    font-size: 0.95rem;
    line-height: 1.25;
  }

  .form-label .required {
    color: #e11d48;
    font-size: 0.8rem;
    margin-left: 0.3rem;
  }

  .form-control {
    width: 100%;
    padding: 0.92rem 1rem;
    font-size: 1rem;
    line-height: 1.2;
    border: 1px solid var(--line);
    border-radius: 15px;
    background-color: rgba(255, 255, 255, 0.96);
    color: var(--ink);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  }

  .form-control:focus {
    outline: none;
    border-color: rgba(15, 118, 110, 0.55);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.15);
  }

  .form-text {
    font-size: 0.82rem;
    color: var(--ink-soft);
    margin-top: 0.22rem;
    line-height: 1.3;
  }

  .btn {
    display: block;
    width: 100%;
    padding: 0.98rem;
    font-size: 1.02rem;
    font-weight: 800;
    line-height: 1.15;
    text-align: center;
    border: none;
    border-radius: 17px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  }

  .btn-primary {
    background: linear-gradient(135deg, var(--accent), #159a8c);
    color: white;
    box-shadow: 0 14px 24px rgba(15, 118, 110, 0.22);
  }

  .btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  }

  .btn-secondary {
    width: auto;
    min-width: 6.8rem;
    padding: 0.52rem 0.8rem;
    font-size: 0.82rem;
    background: rgba(86, 98, 106, 0.12);
    color: var(--ink);
    border: 1px solid rgba(86, 98, 106, 0.18);
    box-shadow: none;
    flex-shrink: 0;
  }

  .btn-secondary:hover {
    background: rgba(86, 98, 106, 0.18);
  }

  .btn-danger-lite {
    background: rgba(225, 29, 72, 0.08);
    color: #9f1239;
    border: 1px solid rgba(225, 29, 72, 0.18);
  }

  .card-edit-btn {
    align-self: flex-start;
  }

  .btn:disabled {
    background: #8ea4a0;
    cursor: not-allowed;
    box-shadow: none;
  }

  .section-card {
    background: var(--surface);
    border-radius: 22px;
    padding: 1.1rem 1rem;
    box-shadow: var(--shadow);
    border: 1px solid rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(20px);
  }

  .section-heading {
    margin: 0 0 0.22rem;
    font-size: 1.28rem;
    line-height: 1.16;
    color: var(--ink);
  }

  .section-copy {
    margin: 0 0 0.95rem;
    color: var(--ink-soft);
    font-size: 0.93rem;
    line-height: 1.35;
  }

  .modal-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.46);
    z-index: 1100;
  }

  .modal-overlay.open {
    display: flex;
  }

  .modal-dialog {
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(247, 251, 250, 0.98));
    border-radius: 24px;
    box-shadow: 0 30px 60px rgba(15, 23, 42, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.9);
  }

  .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1rem 0.9rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  }

  .modal-title {
    margin: 0;
    font-size: 1.16rem;
    line-height: 1.2;
    color: var(--ink);
  }

  .modal-close {
    width: auto;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    background: rgba(86, 98, 106, 0.12);
    color: var(--ink-soft);
    box-shadow: none;
  }

  .modal-body {
    padding: 1rem;
  }

  .modal-dialog-wide {
    max-width: 880px;
  }

  .modal-body-pdf {
    padding-top: 0.85rem;
  }

  .pdf-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.7rem;
  }

  .pdf-viewer {
    width: 100%;
    min-height: 68vh;
    border: 1px solid rgba(86, 98, 106, 0.16);
    border-radius: 18px;
    background: #fff;
  }

  .pdf-canvas-viewer {
    padding: 0.9rem;
    overflow: auto;
    background:
      linear-gradient(180deg, rgba(248, 250, 252, 0.96), rgba(241, 245, 249, 0.98));
  }

  .pdf-page {
    margin: 0 auto 1rem;
    max-width: 100%;
  }

  .pdf-page:last-child {
    margin-bottom: 0;
  }

  .pdf-page-label {
    margin-bottom: 0.45rem;
    font-size: 0.8rem;
    color: var(--ink-soft);
    text-align: right;
  }

  .pdf-page-canvas {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  }

  .pdf-status-box {
    border: 1px solid rgba(86, 98, 106, 0.14);
    border-radius: 16px;
    padding: 0.9rem;
    background: rgba(255, 255, 255, 0.82);
  }

  .status-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.34rem 0.62rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 800;
  }

  .status-pill.is-complete {
    background: #dcfce7;
    color: #166534;
  }

  .status-pill.is-pending {
    background: #fff2cc;
    color: #7c4a03;
  }

  .pdf-meta {
    margin-top: 0.55rem;
    font-size: 0.88rem;
    color: var(--ink-soft);
    line-height: 1.4;
  }

  .inline-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
    margin-bottom: 1rem;
  }

  @media (min-width: 640px) {
    .app-shell {
      padding-left: 1.25rem;
      padding-right: 1.25rem;
    }

    .header-tools {
      padding-left: 1.25rem;
      padding-right: 1.25rem;
    }

    .status-overview {
      grid-template-columns: repeat(4, minmax(0, 1fr));
    }
  }

  @media (max-width: 639px) {
    .results-toolbar,
    .card-subtitle {
      align-items: stretch;
      flex-direction: column;
    }

    .results-actions,
    .card-actions,
    .inline-actions {
      width: 100%;
    }

    .inline-actions {
      grid-template-columns: 1fr;
    }

    .card-inline-btn,
    .toolbar-btn {
      width: 100%;
    }
  }
