:root{
    --bg:#F5F9FF;
    --card:#ffffff;
    --text:#0B1220;
    --muted:#5A6B86;
    --line:rgba(16,24,40,.10);
    --shadow:0 18px 46px rgba(15,23,42,.10);
    --shadow2:0 26px 70px rgba(15,23,42,.14);
    --blue:#1E66FF;
    --blue2:#2F7BFF;
    --green:#16A34A;
    --red:#EF4444;
    --radius:24px;
  }

  .plan-form{background:var(--bg); padding:56px 0 64px; overflow:hidden;}
  .pf-wrap{max-width:1160px;margin:0 auto;padding:0 20px;}

  /* Adjusted padding for forms, different from plans list */
  .pf-head{margin:0 auto 18px; padding: 0 28px;} /* Default padding for lists/tables */
  .plan-form .pf-head { padding: 0 16px; } /* Specific padding for forms */

  .pf-kicker{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:12px;}
  .pf-pill{
    display:inline-flex;align-items:center;gap:8px;
    padding:8px 12px;border-radius:999px;
    background:rgba(30,102,255,.10);
    border:1px solid rgba(30,102,255,.16);
    color:var(--blue);
    font-weight:600;
    font-size:13px;line-height:1;
    white-space:nowrap;
    cursor:pointer; /* Adding cursor for consistency */
    text-decoration:none; /* THIS IS THE FIX */
  }
  .pf-pill-ghost{
    background:#fff;
    border:1px solid rgba(16,24,40,.10);
    color:var(--text);
    box-shadow:0 10px 22px rgba(15,23,42,.06);
  }
  .pf-title{
    margin:0 0 10px;color:var(--text);
    font-size:34px;line-height:1.15;font-weight:700;
    letter-spacing:-.02em;
  }
  .pf-sub{margin:0;color:var(--muted);font-size:16px;line-height:1.9;font-weight:500;}

  /* Original pf-grid for plan_new/edit, still used in plan_view */
  .pf-grid{display:grid;grid-template-columns:1.1fr .9fr;gap:14px;align-items:start;}

  .pf-card{
    background:rgba(255,255,255,.88);
    border:1px solid rgba(16,24,40,.08);
    border-radius:22px;
    padding:16px;
    box-shadow:0 16px 44px rgba(15,23,42,.08);
    backdrop-filter: blur(10px);
    position:relative;
    overflow:hidden;
  }
  .pf-card:before{
    content:"";
    position:absolute; inset:-2px;
    background:radial-gradient(520px 220px at 30% 10%, rgba(30,102,255,.14), transparent 60%);
    opacity:.9;
    pointer-events:none;
  }

  .pf-card-top{display:flex;align-items:center;justify-content:space-between;gap:12px;position:relative;}
  .pf-ico{
    width:46px;height:46px;border-radius:16px;
    background:rgba(30,102,255,.12);
    border:1px solid rgba(30,102,255,.18);
    display:flex;align-items:center;justify-content:center;
    color:var(--blue);font-size:18px;
    box-shadow:0 10px 22px rgba(15,23,42,.06);
  }
  .pf-badge{
    display:inline-flex;align-items:center;justify-content:center;
    padding:7px 10px;border-radius:999px;
    background:#fff;border:1px solid rgba(16,24,40,.08);
    color:rgba(11,18,32,.78);
    font-weight:600;
    font-size:12px;
    box-shadow:0 10px 22px rgba(15,23,42,.06);
    white-space:nowrap;
  }
  .pf-badge-strong{
    background:linear-gradient(135deg, rgba(30,102,255,.12), rgba(47,123,255,.10));
    border:1px solid rgba(30,102,255,.22);
    color:var(--text);
  }

  .pf-block{margin-top:14px;position:relative;}
  .pf-block-h{
    color:var(--text);font-weight:600;
    font-size:14px;letter-spacing:-.01em;
    display: flex; align-items: center; gap: 8px; /* For icons in new design */
  }

  .pf-fields{
    margin-top:10px;
    display:grid;
    grid-template-columns:repeat(auto-fit, minmax(280px, 1fr)); /* Responsive grid for form fields */
    gap:10px;
  }
  .pf-field span{display:block;color:var(--muted);font-size:12px;font-weight:500;
    margin:0 0 6px;}
  .pf-input{
    width:100%;
    padding:12px 12px;
    border-radius:14px;
    border:1px solid rgba(16,24,40,.10);
    background:#fff;
    color:var(--text);
    font-weight:500;
    outline:none;
    box-shadow:0 10px 22px rgba(15,23,42,.06);
  }
  .pf-input:focus{border-color:rgba(30,102,255,.35); box-shadow:0 18px 34px rgba(30,102,255,.14);}

  .pf-row-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px;}
  .pf-add{
    display:inline-flex;align-items:center;gap:10px;
    padding:10px 12px;border-radius:14px;
    background:#fff;color:var(--blue);
    border:1px solid rgba(30,102,255,.26);
    font-weight:600;
    font-size:13px;
    box-shadow:0 10px 22px rgba(15,23,42,.06);
    cursor:pointer;
  }
  .pf-add:hover{box-shadow:0 14px 26px rgba(15,23,42,.10); transform:translateY(-1px);}

  .pf-rows{display:flex;flex-direction:column;gap:14px;} /* Gap between service item cards */

  .pf-status{ /* This is for dropdowns inside forms now */
    display:flex;align-items:center;justify-content:space-between;gap:8px;
    padding:10px 10px;border-radius:14px;
    border:1px solid rgba(16,24,40,.10);
    background:#fff;
    font-weight:500;
  }
  .pf-status .pf-dot{
    width:10px;height:10px;border-radius:999px;background:rgba(16,24,40,.25);
  }
  .pf-status[data-s="done"]{border-color:rgba(22,163,74,.25);}
  .pf-status[data-s="done"] .pf-dot{background:var(--green);}
  .pf-status[data-s="cancel"]{border-color:rgba(239,68,68,.22);}
  .pf-status[data-s="cancel"] .pf-dot{background:var(--red);}
  .pf-status[data-s="plan"] .pf-dot{background:rgba(30,102,255,.6);}

  .pf-del{
    width:42px;height:42px;
    border-radius:14px;
    border:1px solid rgba(16,24,40,.10);
    background:#fff;
    cursor:pointer;
    display:flex;align-items:center;justify-content:center;
    box-shadow:0 10px 22px rgba(15,23,42,.06);
  }
  .pf-del i{color:rgba(11,18,32,.6);}
  .pf-del:hover i{color:var(--red);}

  .pf-total{
    margin-top:12px;
    display:flex;align-items:flex-end;justify-content:space-between;gap:10px;
    padding:14px 14px;border-radius:18px;
    background:rgba(255,255,255,.92);
    border:1px solid rgba(16,24,40,.08);
    box-shadow:0 14px 36px rgba(15,23,42,.08);
  }
  .pf-total-k{font-weight:600;
    color:var(--text);font-size:14px;}
  .pf-total-hint{margin-top:2px;color:var(--muted);font-weight:400;
    font-size:12.5px;}
  .pf-total-v{font-weight:700;
    font-size:22px;color:var(--text);letter-spacing:-.02em;}

  .pf-actions-card {
    padding-top: 24px;
    background: none;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
  }
  .pf-actions{margin-top:0;display:flex;gap:10px;flex-wrap:wrap; justify-content: flex-end;}
  .pf-btn{
    display:inline-flex;align-items:center;justify-content:center;gap:10px;
    padding:12px 14px;border-radius:14px;
    background:linear-gradient(135deg,var(--blue),var(--blue2));
    color:#fff;text-decoration:none;
    font-weight:600;
    font-size:14px;
    border:1px solid rgba(30,102,255,.25);
    cursor:pointer;
    transition:transform .15s ease, box-shadow .15s ease;
    white-space:nowrap;
  }
  .pf-btn:hover{transform:translateY(-1px);box-shadow:0 18px 34px rgba(30,102,255,.22);}
  .pf-btn-ghost{
    background:#fff;color:var(--blue);
    border:1px solid rgba(30,102,255,.26);
    box-shadow:0 10px 22px rgba(15,23,42,.06);
    font-weight:600;
  }
  .pf-btn-ghost:hover{box-shadow:0 14px 26px rgba(15,23,42,.10);}

  .pf-note{
    margin-top:10px;
    display:flex;gap:10px;align-items:flex-start;
    color:var(--muted);
    font-weight:400;
    font-size:13.5px;
    line-height:1.7;
  }
  .pf-note i{color:var(--blue); margin-top:2px;}


  /*
  --- Styles for Service Item Cards (new forms) ---
  */
  .form-item-card {
    background: rgba(255,255,255,.90);
    border: 1px solid rgba(16,24,40,.08);
    border-radius: 18px;
    padding: 14px;
    box-shadow: 0 12px 30px rgba(15,23,42,.06);
    position: relative;
    overflow: hidden;
  }
  .form-item-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
  }
  .form-item-head .pf-block-h {
    margin: 0; /* Override default pf-block-h margin */
  }
  .form-item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
  }


  @media (max-width: 980px){
    .plan-form{padding:46px 0 54px;}
    .pf-title{font-size:28px;}
    /* .pf-grid becomes single column from form-layout */
    .pf-fields{grid-template-columns:1fr;} /* Keep this for general form fields */
    /* .pf-line is removed */

    /* --- Responsive Tables --- */
    .plans-table, .services-table {
        border: none;
        box-shadow: none;
    }
    .plans-table thead, .services-table thead {
        display: none; /* Hide table headers on mobile */
    }
    .plans-table tr, .services-table tr {
        display: block;
        border: 1px solid var(--line);
        border-radius: 16px;
        margin-bottom: 16px;
        box-shadow: var(--shadow);
    }
    .plans-table td, .services-table td {
        display: block; /* Each cell is a block */
        padding: 10px 14px;
        border-bottom: 1px solid var(--line);
        text-align: left; /* All text is left-aligned */
    }
    .plans-table tr td:last-child, .services-table tr td:last-child {
        border-bottom: none; /* No border for the last cell */
    }
    .plans-table td:before, .services-table td:before {
        content: attr(data-label);
        display: block;
        font-weight: 600;
        color: var(--muted);
        font-size: 0.85em;
        margin-bottom: 4px;
    }
    /* First cell (patient name) becomes a header */
    .plans-table tr td:first-child, .services-table tr td:first-child {
        padding-top: 14px;
        padding-bottom: 14px;
        border-bottom: 1px solid var(--line);
    }
    /* Don't show a label for the patient name or actions */
    .plans-table td:first-child:before, .services-table td:first-child:before,
    .plans-table td:last-child:before, .services-table td:last-child:before {
        display: none;
    }
    .plans-table .plan-patient-col b, .services-table .plan-patient-col b {
        font-size: 1.15em;
        font-weight: 600;
        color: var(--text);
    }
    /* Actions cell */
    .plans-table td:last-child, .services-table td:last-child {
        background-color: rgba(245,249,255, .5);
        padding-top: 12px;
        padding-bottom: 12px;
    }
    .plans-table .plans-actions, .services-table .plans-actions {
        display: flex;
        justify-content: flex-end; /* Align buttons to the right */
        gap: 10px;
    }
  }

/* Styles for services table */
.services-table, .plans-table {
  width: 100%;
  border-collapse: collapse;
}
.services-table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.services-table td {
  padding: 12px;
  font-size: 14px;
  border-bottom: 1px solid rgba(16,24,40,.08);
}

.services-table tbody tr:last-child td {
  border-bottom: none;
}

.services-table .services-table-header {
  background: rgba(245,249,255,.75);
  border-bottom: 1px solid rgba(16,24,40,.08);
}

.services-table td:nth-child(1) { /* Code column */
  color: var(--muted);
  font-weight: 500;
}
.services-table td:nth-child(2) { /* Name column */
  color: var(--text);
  font-weight: 500;
}
.services-table td:nth-child(3) { /* Price column */
  text-align: right;
  color: var(--text);
  font-weight: 500;
}
.services-table td:nth-child(4) { /* Active column */
  text-align: center;
}

.services-table td:nth-child(5) { /* Actions column */
  text-align: center;
}

/* Styles for plans table */
.plans-table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.plans-table td {
  padding: 12px;
  font-size: 14px;
  border-bottom: 1px solid rgba(16,24,40,.08);
  vertical-align: middle;
}

.plans-table tbody tr:last-child td {
  border-bottom: none;
}

.plans-table-header {
  background: rgba(245,249,255,.75);
  border-bottom: 1px solid rgba(16,24,40,.08);
}

.plans-table .plan-patient-col b {
  font-weight: 600;
  color: var(--text);
}
.plans-table .plan-patient-meta {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 2px;
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.status-active {
  background: rgba(30,102,255,.10);
  border: 1px solid rgba(30,102,255,.16);
  color: var(--blue);
}
.status-done {
  background: rgba(22,163,74,.10);
  border: 1px solid rgba(22,163,74,.16);
  color: var(--green);
}
.status-default {
  background: rgba(16,24,40,.05);
  border: 1px solid rgba(16,24,40,.10);
  color: var(--muted);
}

/* Action buttons in table */
.plans-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
}
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(16,24,40,.08);
  background: #fff;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: all .15s ease;
  text-decoration: none;
}
.action-btn:hover {
  background: rgba(30,102,255,.08);
  border-color: rgba(30,102,255,.2);
  color: var(--blue);
  box-shadow: 0 4px 12px rgba(15,23,42,.05);
}
.action-btn i {
  /* No specific font-weight, inherits */
}

.delete-plan-btn:hover {
    color: var(--red);
    border-color: rgba(239,68,68,.2);
    background: rgba(239,68,68,.08);
}

/*
--- Styles for Plan View Page (`plan_view.html`) ---
*/

/* Info Card (Left Column) */
.plan-view-info {
  align-self: start;
}

.plan-view-meta-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.plan-view-meta-list li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.plan-view-meta-list li:last-child {
  border-bottom: none;
}

.plan-view-meta-list li span {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.plan-view-meta-list li strong {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.plan-view-total {
  font-size: 18px !important;
  font-weight: 700 !important;
  color: var(--blue) !important;
}

.plan-view-note {
  margin-top: 16px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.6;
}

/* Services Card (Right Column) */
.plan-view-services .pf-block-h {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.plan-view-items-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
}

.plan-view-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.plan-view-item:last-child {
  border-bottom: none;
}

.plan-view-item-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.plan-view-status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  font-size: 12px;
}

.plan-view-status-icon.status-plan {
  background-color: rgba(30, 102, 255, 0.1);
  color: var(--blue);
}
.plan-view-status-icon.status-done {
  background-color: rgba(22, 163, 74, 0.1);
  color: var(--green);
}
.plan-view-status-icon.status-cancel {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--red);
}

.plan-view-item-name {
  font-weight: 600;
  font-size: 15px;
}

.plan-view-item-tooth {
  font-weight: 500;
  color: var(--muted);
  font-size: 13px;
  margin-left: 4px;
}

.plan-view-item-price {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
}

/* Responsive adjustments for the new layout */
@media (max-width: 980px) {
  .pf-grid {
    grid-template-columns: 1fr !important;
  }
  .plan-view-info, .plan-view-services {
    align-self: auto;
  }
}